<?php
$query_string[2] = (int)$query_string[2];
if ($query_string[2]==0) $query_string[2] = 1;

if ($_POST['user_name']<>"")
{
	$search = $sql->escape($_POST['user_name']);
	$sql->mysql_select("users", "*"," `user_login` LIKE '%".$search."%'","`user_login` DESC");
}
else
{
	$sql->mysql_select("users", "*","`user_ban` = 0");
	$max = $sql->get_mysql_num_row();

	$sql->mysql_select("users", "*","`user_ban` = 0","`user_login` DESC",(($query_string[2]-1)*20).", 20");
}

$page_title = "Felhasználók listázása";
$page_text = "
	<table cellpadding='0' cellspacing='0' class='admin_list ui-corner-all'>
		<tr class='admin_list_header'>
			<td class='admin_list_id ui-widget-header ui-corner-bottom'>
				Azonosító
			</td>
			<td class='ui-widget-header ui-corner-bottom'>
				Felhasználó login név
			</td>
			<td class='ui-widget-header ui-corner-bottom admin_list_date'>
				Regisztráció dátuma
			</td>
			<td class='admin_list_action ui-widget-header ui-corner-bottom'>
				Műveletek
			</td>
		</tr>
";

while ($row = $sql->get_line())
{
	$row['user_regdate'] = date("Y-m-d",$row['user_regdate']);
	$page_text .= "
		<tr class='admin_list_body'>
			<td class='admin_list_id'>
				".$row['user_id']."
			</td>
			<td class='admin_list_category'>
				".$row['user_login']."
			</td>
			<td class='admin_list_date'>
				".$row['user_regdate']."
			</td>
			<td class='admin_list_action'>
				<a href='index.php?users.edit.".$row['user_id']."' class='ui-icon ui-icon-pencil' title='Szerkesztés'></a>
				<a href='modules/users/users_ban.php?&id=".$row['user_id']."' class='ui-icon ui-icon-trash' title='Törlés'></a>
			</td>
		</tr>
	";
}

$page_text .= "
	</table>
	<div class='form_search'>
		<form method='post' action='index.php?users.list'>
			<label>Keresés</label>
			<input class='text ui-widget-content ui-corner-all' type='text' name='user_name' value='".$_POST['user_name']."' />
			<div class='admin_button'>
				<input class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' type='submit' value='keresés' />
			</div>
		</form>
	</div>
";

$page_text .= "<div id='smart-paginator'></div>";

$theme->footer_jssrc[] = "
	$('#smart-paginator').smartpaginator({ totalrecords: ".$max.", recordsperpage: 20, initval:".$query_string[2]." , next: 'Következő', prev: 'Előző', first: 'Első', last: 'Utolsó', theme: 'black', onchange: onChange});
	
	function onChange(newPageValue) {
		window.location.href= 'index.php?news.list.'+newPageValue;
	}
";
?>